package com.yiren.manager.ctrl.view;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yiren.core.exception.MyException;
import com.yiren.core.repository.utils.QueryResult;
import com.yiren.core.utils.HTTPResult;
import com.yiren.entity.ViewElderArrearage;
import com.yiren.manager.service.iface.view.ViewElderArrearageService;

@RequestMapping("viewElderArrearage")
@Controller
public class ViewElderArrearageController {
	
	@Autowired
	private ViewElderArrearageService selfService;
	
	@RequestMapping("find")
	@ResponseBody
	public HTTPResult<ViewElderArrearage> find(String elderId) throws MyException{
		HTTPResult<ViewElderArrearage> result = new HTTPResult<ViewElderArrearage>();
		String sqlWhere = "elder_id=?1";
		QueryResult<ViewElderArrearage> qr = selfService.find(ViewElderArrearage.class, sqlWhere,new Object[]{elderId});
		
		List<ViewElderArrearage> resultList = new ArrayList<ViewElderArrearage>();
		for(ViewElderArrearage entity : qr.getResultList()){
			resultList.add(entity);
		}
		result.setData(resultList);
		
		return result;
	}
}
